#include "stdio.h"
#include <stdint.h>
#include "../section_locate.h"
#include "pt-thread.h"
#include "my_utils.h"


static void stack_adt_test(void);
PLACE_FUNC_AT_SEC(stack_adt_test);


DEFINE_STACK(float_stack, 8, float);

static void stack_adt_test(void)
{
    //============= float 型的stack =====================
    float float_val = 1.5f;
    stack_push(float_stack, &float_val);
    float_val = 33.5f;
    stack_push(float_stack, &float_val);
    float_val = 6.6f;
    stack_push(float_stack, &float_val);

    float_val = 0;
    stack_pop(float_stack, &float_val);
    printf("float_val = %f\n", float_val);
    stack_pop(float_stack, &float_val);
    printf("float_val = %f\n", float_val);
    stack_pop(float_stack, &float_val);
    printf("float_val = %f\n", float_val);

    //============= 破坏测试 ==============
//    float_stack->element_cnt = 125743;  // 编译报错, 不完整类型不能访问到结构体成员
//    float_stack->stack_size = 0;


    //============= char 型的stack =====================
    stack_t char_stack = stack_create(16, sizeof(char));
    char char_val = 5;
    stack_push(char_stack, &char_val);
    char_val = 47;
    stack_push(char_stack, &char_val);

    char_val = 0;
    stack_pop(char_stack, &char_val);
    printf("char_val = %d\n", char_val);
    stack_pop(char_stack, &char_val);
    printf("char_val = %d\n", char_val);

    stack_destroy(char_stack);

}


